// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

using System;
using System.Data.Common;
using System.Threading;
using System.Threading.Tasks;

namespace SnapObjects.Data
{
    /// <summary>
    ///     Represents the database transaction.
    /// </summary>
    public interface IAdoDbTransaction : IDisposable
    {
        /// <summary>
        ///     Gets the GUID of the current IAdoDbTransaction object.
        /// </summary>
        Guid TransactionId { get; }

        /// <summary>
        ///     Gets the internal DbTransaction object.
        /// </summary>
        DbTransaction DbTransaction { get; }

        /// <summary>
        ///     Commits the database transaction.
        /// </summary>
        void Commit();

        /// <summary>
        ///     Rolls back the database transaction.
        /// </summary>
        void Rollback();

        Task CommitAsync();

        Task CommitAsync(CancellationToken cancellationToken);

        Task RollbackAsync();

        Task RollbackAsync(CancellationToken cancellationToken);
    }
}
